\fc1\cf1 I am trying to draw something to my view and am getting the message:\
\
\f1\fs24 Assertion failed: No REAL window during lockFocus on a view\
\f0\fs28\fc0\cf0 \
I've checked and the window instance variable of the view is non-nil. Why am I getting this message?\
\
A:
\fc1\cf1 A REAL window is a PostScript window. Your check for a non-nil window assures that you have a AppKit-side window, but it doesn't check to make sure there is an associated PostScript window. When you grab a window in InterfaceBuilder, it is deferred by default. When a window is deferred the associated PostScript window won't be created until you actually bring that window on screen. You cannot draw to a window which doesn't yet have a PostScript window. You can change the deferred status using the “Deferred” switch button on the InterfaceBuilder Window inspector or with the proper argument to the Window method (
\b initContent:style:backing:buttonMask:defer:
\b0 ). If you're ever in doubt about a view's status, you can use the
\b canDraw
\b0 method which returns a boolean which indicates whether you are able to draw to that view.\